PicoOPC User's Guide and Reference
Application Parameters

OPC UA communication requires the client to pass certain information about itself to the server. This information is contained in the properties of Client object and comprises of:

PicoOPC has some defaults for the above parameters, but for anything other than simple tests and experiments, you should change them to proper values that reflect the reality of your application.

Following example shows how to do it.

// This example shows how to set the application parameters.

using System;
using OpcLabs.PicoOpc.UA;

namespace ConsoleApp._Client
{
    class ApplicationParameters
    {
        public static void Main1()
        {
            // Instantiate the client object, and set its application parameters.
            var client = new Client
            {
                ApplicationName = "My Application",
                ApplicationUri = new Uri("http://www.mycompany.com/MyApplication"),
                ProductUri = new Uri("http://www.mycompany.com/MyProduct")
            };

            // The remainder of this example is not that relevant, it just reads a node and displays the result.

            try
            {
                try
                {
                    // Connect to the server.
                    Console.WriteLine();
                    Console.WriteLine("Connecting...");
                    client.Connect(new Uri("opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"));

                    // Read a node.
                    Console.WriteLine();
                    Console.WriteLine("Reading...");
                    var nodeId = new NodeId(10221, namespaceIndex:2);
                    DataValue dataValue = client.Read(TimeSpan.Zero, new[] { new ReadValueId(nodeId) })[0];

                    // Display the result.
                    Console.WriteLine();
                    Console.WriteLine($"Status code: 0x{dataValue.StatusCode:X8}");
                    Console.WriteLine($"Server timestamp: {DateTime.FromFileTimeUtc(dataValue.ServerTimestamp)}");
                    Console.WriteLine($"Source timestamp: {DateTime.FromFileTimeUtc(dataValue.SourceTimestamp)}");
                    Console.WriteLine($"Built-in type: {dataValue.Variant.BuiltInType}");
                    Console.WriteLine($"Is array: {dataValue.Variant.IsArray}");
                    Console.WriteLine($"Value: {dataValue.Variant.Value}");
                }
                finally
                {
                    if (client.IsConnected)
                    {
                        // Disconnect from the server.
                        Console.WriteLine();
                        Console.WriteLine("Disconnecting...");
                        client.Disconnect();
                    }
                }
            }
            catch (AggregateException aggregateException)
            {
                Console.WriteLine("*** Failure: {0}", aggregateException.GetBaseException().Message);
            }
        }
    }
}